package com.vito.dcs.pad.action;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.model.Result;
import com.vito.base.tools.I18nResMsg;
import com.vito.dcs.pad.service.PadBindService;

@Controller
@RequestMapping("/dcs/pad")
public class PadBindAction {

	private static final Logger log = LoggerFactory.getLogger(PadBindAction.class);
	
	@Reference
	private PadBindService padBindService;
	
	@RequestMapping("/savePadBind")
	@ResponseBody
	public Result savePadBind(@RequestParam Map<String, Object> map){
		Result res = new Result();
		try {
			padBindService.savePadBind(map);
			res.setCode(Result.CODE_OK);
			res.setMsg(I18nResMsg.SAVESUC());
		} catch (Exception e) {
			log.error(I18nResMsg.EXECERR(), e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
		}
		return res;
	}
	@RequestMapping("/queryPadBind")
	@ResponseBody
	public Result queryPadBind(@RequestParam Map<String, Object> map){
		Result res = new Result();
		try {
			Map<String, Object> queryPadBind = padBindService.queryPadBind(map);
			res.setCode(Result.CODE_OK);
			res.setData(queryPadBind);
		} catch (Exception e) {
			log.error(I18nResMsg.EXECERR(), e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
		}
		return res;
	}
	@RequestMapping("/queryCascadeTree")
	@ResponseBody
	public Result queryCascadeTree(@RequestParam Map<String, Object> map){
		Result res = new Result();
		try {
			List<Map<String, Object>> queryCascadeTree = padBindService.queryCascadeTree(map);
			res.setCode(Result.CODE_OK);
			res.setData(queryCascadeTree);
		} catch (Exception e) {
			log.error(I18nResMsg.EXECERR(), e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
		}
		return res;
	}
	@RequestMapping("/queryVehicleBySectionId")
	@ResponseBody
	public Result queryVehicleBySectionId(@RequestParam Map<String, Object> map){
		Result res = new Result();
		try {
			List<Map<String, Object>> queryVehicleBySectionId = padBindService.queryVehicleBySectionId(map);
			res.setCode(Result.CODE_OK);
			res.setData(queryVehicleBySectionId);
		} catch (Exception e) {
			log.error(I18nResMsg.EXECERR(), e);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
		}
		return res;
	}
	
}
